function output = load_data(location,type,indexes, keyword, num_episodes)

if strcmp(location, 'home')
    home_path = '/home/georgi/Desktop/Project/';
elseif strcmp(location, 'dice')    
    home_path = '/afs/inf.ed.ac.uk/user/s07/s0785186/Desktop/Project/';
end

times = zeros(1,numel(indexes));
ratios = zeros(1,numel(indexes));
num_passes = zeros(1,numel(indexes));
%thetas = zeros(1,numel(indexes));

if strcmp('policy',type)
    path = 'policies/';

    for i = 1:numel(indexes)
        index = indexes(i);
        policy_name = strcat(type,'_',num2str(index),'_',keyword);
        data = loadfile(home_path,path,policy_name);
        times(i) = data.time;
%        parameters{i} = data.parameters;
        possession(i) = data.possession_per_episode;
        reward_per_episode(i) = data.reward_per_episode;
        random_per_episode(i) = data.random_per_episode;
        ratios(i) = data.ratio;
    end
    
    output = struct('times',times,'ratios',ratios,'possession_per_episode',possession,'reward_per_episode',reward_per_episode,'random_per_episode',random_per_episode);
elseif strcmp(type,'results')
    path = 'results/';
    
    for i = 1:numel(indexes)
        index = indexes(i);
        result_name = strcat(type,'_policy_',num2str(index),'_',keyword,'_',num2str(num_episodes));
        data = loadfile(home_path,path,result_name);
        
        times(i) = data.time;
        ratios(i) = data.ratio;
        num_passes(i) = data.passes_per_episode;
        
        possession(i) = data.possession_per_episode;
        reward_per_episode(i) = data.reward_per_episode;
    end
    
    output = struct('times',times,'ratios',ratios,'num_passes',num_passes,'possession_per_episode',possession,'reward_per_episode',reward_per_episode);
else
    'ERROR: wrong argument for type'
    output = {};
end


end
